﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace Webcar.Controls
{
    public partial class SelectByYearQuar : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.IsPostBack)
                return;
            //if (this.SearchClick != null)
            //    this.Button1.Click += new EventHandler(this.SearchClick);
            this.BindQuart();
            //DropDownListManager.BindDropDownDW(this.DropDownList1);
            this.TextBox1.Text = DateTime.Now.Year.ToString();
        }
        public delegate void OnSearchClickDelegate(object sender, EventArgs e);
        public event OnSearchClickDelegate SearchClick;

        private void BindQuart()
        {
            ListItem li = new ListItem("第一季度", "0");
            ListItem li2 = new ListItem("第二季度", "3");
            ListItem li3 = new ListItem("第三季度", "6");
            ListItem li4 = new ListItem("第四季度", "9");
            this.DropDownList1.Items.Add(li);
            this.DropDownList1.Items.Add(li2);
            this.DropDownList1.Items.Add(li3);
            this.DropDownList1.Items.Add(li4);
            li.Selected = true;
        }
        public string GetYear()
        {
            return this.TextBox1.Text;
        }
        public string GetQuarter()
        {
            return this.DropDownList1.SelectedValue;
        }
        public void SetError(string text)
        {
            this.lblError.Text = text;
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            this.SetError("");
            if (this.GetQuarter() == "")
            {
                this.SetError("请选择季度。");
                return;
            }
            if (this.GetYear() == "")
            {
                this.SetError("请选择统计年度。");
                return;
            }

            if (SearchClick != null) SearchClick(this.Button1, e);
        }

    }
}